/**
 * 计算数组的笛卡尔积
 */

function product(xList: number[], yList: number[]): [number, number][] {
  return xList.reduce((acc, cur) => acc.concat(yList.map(item => [cur, item])), [] as [number, number][]);
}

// 测试
console.log(product([1, 2], [3, 4])); // [[1,3],[1,4],[2,3],[2,4]]
